package com.stars.control.user.controller;

import com.stars.base.entity.Result;
import com.stars.base.entity.UserSelectDTO;
import com.stars.control.user.service.StarUserSelectService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author : moon
 * @version : 1.0
 * @date : 2023/4/13 17:21
 * @description : 用户选择控件
 */
@RestController
@RequestMapping("/userSelect")
public class StarUserSelectController {

    private final StarUserSelectService selectService;

    public StarUserSelectController(StarUserSelectService starUserSelectService) {
        this.selectService = starUserSelectService;
    }

    /**
     * 异步获取用户数据
     * @author : moon
     * @date :  2023/4/13 17:21
     * @param: request
     * @return: com.stars.base.entity.Result
     */
    @PostMapping("/data")
    public Result loadUserByDeptId(HttpServletRequest request){
        return Result.success(selectService.data(request));
    }

    /**
     * 用户组件树数据
     * @param dto 通用查询条件封装
     */
    @PostMapping("/loadAllUserTree")
    public Result loadAllUserTree(@RequestBody UserSelectDTO dto){
        return Result.success(selectService.loadAllUserTree(dto));
    }
}
